//
//  StoreInformationTwoTableViewCell.m
//  GLGW_Shoping
//
//  Created by whx on 2018/12/10.
//  Copyright © 2018年 yang. All rights reserved.
//

#import "StoreInformationTwoTableViewCell.h"
#import "GLGWTagsView.h"

@implementation StoreInformationTwoTableViewCell
{
    GLGWLabel *deLab;
    GLGWTagsView *bottomTageView;
}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        
        GLGWView *topView = [[GLGWView alloc] initWithInSuperView:self.contentView];
        topView.backgroundColor = [UIColor colorWithHexString:@"#EAEAEA"];
        [topView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(self.contentView);
            make.left.equalTo(self.contentView.mas_left).offset(kWidthProportion_In_iPhoneTriploid(15));
            make.right.equalTo(self.contentView.mas_right).offset(-kWidthProportion_In_iPhoneTriploid(15));
            make.height.equalTo(@(kHeightProportion_In_iPhoneTriploid(1)));
        }];
        
        GLGWLabel *leftLab = [[GLGWLabel alloc] initWithFont:SYSTEMFONT(16) theColor:kColor_Rule_Black inSuperView:self.contentView];
        leftLab.text = @"主营区域";
        [leftLab mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(topView.mas_left);
            make.top.equalTo(topView.mas_bottom).offset(kHeightProportion_In_iPhoneTriploid(20));
            make.bottom.equalTo(@(-kHeightProportion_In_iPhoneTriploid(20)));
        }];
        deLab = leftLab;
        
        GLGWImageView *riIV = [[GLGWImageView alloc] initWithImageName:@"icon_chakan" inSuperView:self.contentView];
        [riIV mas_makeConstraints:^(MASConstraintMaker *make) {
            make.right.equalTo(self.contentView.mas_right).offset(-kWidthProportion_In_iPhoneTriploid(16));
            make.width.equalTo(@(kWidthProportion_In_iPhoneTriploid(8)));
            make.height.equalTo(@(kHeightProportion_In_iPhoneTriploid(14)));
            make.centerY.equalTo(leftLab.mas_centerY);
        }];
    }
    return self;
}

- (void)setDetailStrArr:(NSArray *)detailStrArr
{
    _detailStrArr = detailStrArr;
    FFTagsViewConfig *config = [self tagViewConfig];

    if (bottomTageView) {
        [bottomTageView removeFromSuperview];
        bottomTageView = nil;
    }

    bottomTageView = [[GLGWTagsView alloc] initWithFrame:CGRectMake(kWidthProportion_In_iPhoneTriploid(6), kHeightProportion_In_iPhoneTriploid(52), KScreenWidth - kWidthProportion_In_iPhoneTriploid(30), 0) tagsArray:detailStrArr config:config tagBackImgStr:@""];
    [self.contentView addSubview:bottomTageView];
    
    CGFloat taH = [bottomTageView heighttagsArray:detailStrArr config:[self tagViewConfig]] + kHeightProportion_In_iPhoneTriploid(30);
    [deLab mas_updateConstraints:^(MASConstraintMaker *make) {
        make.bottom.equalTo(@(-taH));
    }];
//    [self.contentView mas_updateConstraints:^(MASConstraintMaker *make) {
//        make.height.equalTo(@(taH + kHeightProportion_In_iPhoneTriploid(42)));
//    }];
}

- (FFTagsViewConfig *)tagViewConfig
{
    FFTagsViewConfig *config = [[FFTagsViewConfig alloc] init];
    config.itemHeight = kHeightProportion_In_iPhoneTriploid(20);
    config.itemHerMargin = kWidthProportion_In_iPhoneTriploid(0);
    config.itemVerMargin = kHeightProportion_In_iPhoneTriploid(6);
    config.hasBorder = NO;
    config.itemContentEdgs = 0;
    config.topBottomSpace = 0.1;
    config.fontSize = 14.0;
    config.isCanSelected = YES;
    config.isCanCancelSelected = NO;
    config.isMulti = YES;
    config.normalTitleColor = [UIColor colorWithHexString:@"#666666"];
    config.selectedTitleColor = [UIColor colorWithHexString:@"#666666"];
    return config;
}


@end
